package br.fatec.webservice.model;

import java.io.ByteArrayOutputStream;
import java.sql.Timestamp;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;

@Root
public class Formula 
{
	@Attribute
	private Integer codigo;
	
	@Element
	private String nome;

	@Element
	private br.fatec.model.entity.Formula.Status status;

	@Element
	private Timestamp data;

	@Element
	private Cliente cliente;

	public Integer getCodigo() {
		return codigo;
	}

	public void setCodigo(Integer codigo) {
		this.codigo = codigo;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public br.fatec.model.entity.Formula.Status getStatus() {
		return status;
	}

	public void setStatus(br.fatec.model.entity.Formula.Status status) {
		this.status = status;
	}

	public Timestamp getData() {
		return data;
	}

	public void setData(Timestamp data) {
		this.data = data;
	}

	public Cliente getCliente() {
		return cliente;
	}

	public void setCliente(Cliente cliente) {
		this.cliente = cliente;
	}
	
	public String getXml() throws Exception
	{
		ByteArrayOutputStream os = new ByteArrayOutputStream();
		Serializer serializer = new Persister();
		
		String schema = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";

		serializer.write(this, os);

		schema += os.toString("UTF-8");

		return schema;
	}
}
